package org.eece262.taskshareserver;

import com.google.appengine.api.datastore.Key;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.edu.eece262.taskshare.Messages;

@PersistenceCapable
public class User {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private String Username;
    
    @Persistent
    private String Name;
    
    @Persistent
    private String Password;
    
    @Persistent
    private String PhoneNumber;

	@Persistent
    private String Email;
	
	@Persistent
	private int AccessLevel;
	
	public static class AccessLevelType {
		public final int INVISIBLE = 0;
		public final int USER = 1;
		public final int USEREMAIL = 2;
		public final int USERPHONE = 3;
		public final int USEREMAILPHONE = 4;
	}

    public User(String username, String password, String phone, String email, String name, int access_level) {
        Username = username;
        Password = password;
        PhoneNumber = phone;
        Email = email;
        Name = name;
        AccessLevel = access_level;
    }

    public Key getKey() {
        return key;
    }

    public String getUsername() {
        return Username;
    }

    public String getPassword() {
        return Password;
    }

    public void setUsername(String username) {
        this.Username = username;
    }

    public void setPassword(String password) {
        this.Password = password;
    }
    
    public String getPhoneNumber() {
		return PhoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		PhoneNumber = phoneNumber;
	}

	public String getEmail() {
		return Email;
	}

	public void setEmail(String email) {
		Email = email;
	}

	public String getName() {
		return Name;
	}

	public void setName(String name) {
		this.Name = name;
	}

	public int getAccessLevel() {
		return AccessLevel;
	}

	public void setAccessLevel(int accessLevel) {
		AccessLevel = accessLevel;
	}
	
	public Messages.User getMessagesUser() {
		Messages.User rtnValue = new Messages.User();
		rtnValue.setEmail(Email);
		rtnValue.setName(Name);
		rtnValue.setPhonenumber(PhoneNumber);
		rtnValue.setUsername(Username);
		return rtnValue;
	}
}